#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <string.h>
#include <sys/shm.h>
#include <errno.h>

#define SHMKEY 33

typedef struct {
  char file[10][60];
  int n;
} Pile;

int main(){
  char file[60];
  int m;
  Pile *pile;
  m = shmget(SHMKEY, sizeof(Pile), 0);
  if (m < 0) {
    perror("shmget");
    return EXIT_FAILURE;
  }
  if ((pile = (Pile *)shmat(m, NULL, 0)) < (Pile *) 0) {
    perror("shmat"); /* Boucle d'attente */
    exit(EXIT_FAILURE);
  }
  /* Boucle d'attente */
  do {
    printf("Nom du fichier a imprimer (taper '0' pour terminer) ?\n");
    scanf("%s", file);
    if (strcmp(file,"0") == 0){
      break;
    }
    /* Add it to stack  */
    pile->n += 1; /* stack+1 */
    strcpy(pile->file[pile->n],file);  
  } while(1);
  /* Supression du pipe */
  return EXIT_SUCCESS;
}
